package com.linsen.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/** 浏览器类型 */
@Getter
@AllArgsConstructor
public enum BrowserTypeEnum {
    EDGE("Edge"),
    IE11("rv:11.0"),
    IE10("MSIE 10.0"),
    IE9("MSIE 9.0"),
    IE8("MSIE 8.0"),
    IE7("MSIE 7.0"),
    IE6("MSIE 6.0"),
    MAXTHON("Maxthon"),
    QQ("QQBrowser"),
    GREEN("GreenBrowser"),
    SE360("360SE"),
    FIREFOX("Firefox"),
    OPERA("Opera"),
    CHROME("Chrome"),
    SAFARI("Safari"),
    CAMINO("Camino"),
    GECKO("Gecko"),
    UNKNOWN("未识别的浏览器"),
    ;

    /** 特征值 */
    @JsonValue
    private String value;

    private static final Map<String, BrowserTypeEnum> VALUES = new HashMap<>();

    static {
        for (final BrowserTypeEnum browserTypeEnum : BrowserTypeEnum.values()) {
            BrowserTypeEnum.VALUES.put(browserTypeEnum.getValue(), browserTypeEnum);
        }
    }

    @JsonCreator
    public static BrowserTypeEnum getByValue(String value) {
        return BrowserTypeEnum.VALUES.get(value);
    }

    public String value() {
        return this.value;
    }
}
